import 'dart:io';

void main() {
  SmartHome home = SmartHome();
  home.showMenu();
}

class SmartHome {
  bool lights = false;
  int thermostat = 28;
  bool securitySystem = false;

  void showMenu() {
    while (true) {
      print('1. Toggle lights');
      print('2. Set thermostat temperature');
      print('3. Arm/disarm security system');
      print('4. View system status');
      print('5. Exit');
      int choice = int.parse(stdin.readLineSync()!);
      switch (choice) {
        case 1:
          toggleLights();
          break;
        case 2:
          setThermostat();
          break;
        case 3:
          toggleSecuritySystem();
          break;
        case 4:
          viewStatus();
          break;
        case 5:
          exit(0);
        default:
          print('Invalid choice.');
      }
    }
  }

  void toggleLights() {
    lights = !lights;
    print('Lights are now ${lights ? 'ON' : 'OFF'}.');
  }

  void setThermostat() {
    print('Enter temperature (15-30): ');
    int temp = int.parse(stdin.readLineSync()!);
    if (temp < 15 || temp > 30) {
      print('Invalid temperature.');
    } else {
      thermostat = temp;
      if (temp % 3 == 0 && temp % 5 == 0) {
        print('Perfect Day');
      } else if (temp % 3 == 0) {
        print('Cool Day');
      } else if (temp % 5 == 0) {
        print('Warm Day');
      }
    }
  }

  void toggleSecuritySystem() {
    securitySystem = !securitySystem;
    print('Security System is now ${securitySystem ? 'ARMED' : 'DISARMED'}.');
  }

  void viewStatus() {
    print('Lights: ${lights ? 'ON' : 'OFF'}');
    print('Thermostat: $thermostat°C');
    print('Security System: ${securitySystem ? 'ARMED' : 'DISARMED'}');
  }
}
